package com.example.jetpackcomposelearning

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import com.example.jetpackcomposelearning.compose.VideoPlayerScreen

class VideoPlayerActivity : ComponentActivity() {

    companion object {
        const val EXTRA_VIDEO_PATH = "video_path"

        fun newIntent(context: Context, videoPath: String): Intent {
            return Intent(context, VideoPlayerActivity::class.java).apply {
                putExtra(EXTRA_VIDEO_PATH, videoPath)
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val videoPath = intent.getStringExtra(EXTRA_VIDEO_PATH)

        setContent {
            MaterialTheme {
                Surface(color = MaterialTheme.colorScheme.background) {
                    videoPath?.let {
                        VideoPlayerScreen(videoPath = it, onBackPressed = { finish() })
                    }
                }
            }
        }
    }
}